import React from 'react';
import { message } from 'antd';
import JiessMidder from '@jiess/utils/midder';
import {
	$Area,
	$SuperTable,
	$tanInstance,
	$ActionButton,
	$ActionButtons,
	$dialogInstance,
	$TableTools,
	$TableFilter,
	// --------------
	$modules
} from '@/.jiess';
import '@/.jiess/react168antd/css/base.css';
// ===============================================================
export const tools = $modules;
const { JiessEnv, $entry, $component } = $modules;

const jiess = $entry(JiessEnv,
	// 静态注入到jiess实例中
	{
		useRef: React.useRef,
		useEffect: React.useEffect,
		useState: React.useState,
		useReducer: React.useReducer,
		createElement: React.createElement,
		// $render(...args) {
		// 	console.log(args)
		// 	return React.createElement(...args)
		// }
	},
	// 动态注入到组件上下文中
	{
		area: $Area,
		$tan: $tanInstance,
		dialog: $dialogInstance,
		// 定义项目共享中介者
		$midder: new JiessMidder('GlobalMidder', 'no-store'),
		// 注入全局的消息提示
		$msg: (msg, type = 'success') => message[type](msg),
	});
$component('jiess', jiess.JiessComponent);
$component($SuperTable.name, $SuperTable);
$component($ActionButton.name, $ActionButton);
$component($ActionButtons.name, $ActionButtons);
$component($TableTools.name, $TableTools);
$component($TableFilter.name, $TableFilter);
export const JiessComponent = jiess.JiessComponent;